<script>
	import {
		mqttConnect,
		mqttPublish,
		mqttDisconnect
	} from './utils/mqtt.js'
	export default {
		onLaunch: function() {
			console.log('App Launch')
			mqttConnect()
		},
		onShow: function() {
			console.log('App Show')
			uni.$on('mqtt-message', this.handleMessage);
		},
		onHide: function() {
			console.log('App Hide')
			mqttDisconnect()
		},
		beforeDestroy() {
		    uni.$off('mqtt-message', this.handleMessage);
		},
		methods:{
			async handleMessage(msg) {
			    console.log(msg.message)
				if(msg&&uni.getStorageSync("token")){
					let obj = msg.message.split(',')
					let res = await this.http('post','/tc/tcOperate/upSBIP2',{
						clientid:obj[1],
						ip2:obj[0]
					})
					// console.log(res)
				}
			},
		}
	}
</script>

<style lang="less">
	@font-face {
		font-family: 'AHeiTi';
		src: url('~@/static/fonts/AlimamaShuHeiTi-Bold.otf') format('truetype');
	}
	/*每个页面公共css */
	.content{
		width: 100%;
		padding: 20upx 40upx;
		box-sizing: border-box;
	}
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}
	
	.top_view {
		height: var(--status-bar-height);
		width: 100%;
		position: fixed;
		top: 0;
		z-index: 999;
	}
	.null-box{
		width: 100%;
		height: 70vh;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-flow: column;
		image{
			width: 100upx;
			height: auto;
		}
		text{
			font-size: 28upx;
			color: #999;
			display: block;
			margin-top: 20upx;
		}
	}
	.no-more{
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		margin: 20upx 0;
		text{
			font-size: 28upx;
			color: #999;
		}
	}
</style>
